package com.hh.bss.mobile.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.ModelAndView;

import com.hh.bss.auth.client.OnlineManager;
import com.hh.bss.auth.client.OnlineUser;
import com.hh.bss.base.BaseSpringController;
import com.hh.bss.common.page.Page;
import com.hh.bss.customer.vo.query.CompanyQuery;
import com.hh.bss.project.service.ContractJobCvInterviewService;
import com.hh.bss.project.service.ContractJobCvJdService;
import com.hh.bss.project.service.ContractJobCvOfferService;
import com.hh.bss.project.service.ContractJobCvRecomService;
import com.hh.bss.project.service.ContractJobService;
import com.hh.bss.project.service.SearchProjectInterviewService;
import com.hh.bss.project.vo.query.ContractJobCvInterviewQuery;
import com.hh.bss.project.vo.query.ContractJobCvJdQuery;
import com.hh.bss.project.vo.query.ContractJobCvOfferQuery;
import com.hh.bss.project.vo.query.ContractJobCvRecomQuery;
import com.hh.bss.project.vo.query.ContractJobQuery;
@Controller
public class JobController extends BaseSpringController  {
	private ContractJobService contractJobService;
	private ContractJobCvRecomService contractJobCvRecomService;
	private ContractJobCvJdService contractJobCvJdService;
	private ContractJobCvOfferService contractJobCvOfferService;
	private ContractJobCvInterviewService contractJobCvInterviewService;
	
	public void setContractJobCvInterviewServiceImpl(ContractJobCvInterviewService service) {
		this.contractJobCvInterviewService = service;
	}	
	public void setContractJobServiceImpl(ContractJobService service) {
		this.contractJobService = service;
	}	
	public void setContractJobCvRecomServiceImpl(ContractJobCvRecomService service) {
		this.contractJobCvRecomService = service;
	}
	public void setContractJobCvJdServiceImpl(ContractJobCvJdService service) {
		this.contractJobCvJdService = service;
	}	
	public void setContractJobCvOfferServiceImpl(ContractJobCvOfferService service) {
		this.contractJobCvOfferService = service;
	}	
	
	public ModelAndView extlist(HttpServletRequest request, HttpServletResponse response,ContractJobQuery contractJobQuery) throws IOException {
		Page page=contractJobService.findJobPage(contractJobQuery);
		//query.getPageSize(), query.getPageNumber()
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/mobile/job/jobPage");
		
		mv.addObject("pages", page);
		mv.addObject("query", contractJobQuery);
		response.setCharacterEncoding("UTF-8");
		return mv;
		
	}
	//内部推荐
	public ModelAndView innerRecomPage(HttpServletRequest request, HttpServletResponse response,ContractJobCvRecomQuery contractJobCvRecomQuery) throws IOException {
		Page page = contractJobCvRecomService.findJobRecomCvPage(contractJobCvRecomQuery);
		//query.getPageSize(), query.getPageNumber()
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/mobile/job/innerRecomPage");
		
		mv.addObject("pages", page);
		response.setCharacterEncoding("UTF-8");
		return mv;
		
	}
	//外部推荐
	public ModelAndView outerRecomPage(HttpServletRequest request, HttpServletResponse response,ContractJobCvRecomQuery contractJobCvRecomQuery) throws IOException {
		Page page = contractJobCvRecomService.findJobRecomCvPage(contractJobCvRecomQuery);
		//query.getPageSize(), query.getPageNumber()
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/mobile/job/outerRecomPage");
		
		mv.addObject("pages", page);
		response.setCharacterEncoding("UTF-8");
		return mv;
		
	}
	//JD人选
	public ModelAndView jdPage(HttpServletRequest request, HttpServletResponse response,ContractJobCvJdQuery contractJobCvJdQuery) throws IOException {
		Page page = contractJobCvJdService.findPage(contractJobCvJdQuery);
		//query.getPageSize(), query.getPageNumber()
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/mobile/job/jdPage");
		
		mv.addObject("pages", page);
		response.setCharacterEncoding("UTF-8");
		return mv;
		
	}
	//录用offer
	public ModelAndView offerPage(HttpServletRequest request, HttpServletResponse response,ContractJobCvOfferQuery contractJobCvOfferQuery) throws IOException {
		Page page = contractJobCvOfferService.findJobCvOfferPage(contractJobCvOfferQuery);
		//query.getPageSize(), query.getPageNumber()
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/mobile/job/offerPage");
		
		mv.addObject("pages", page);
		response.setCharacterEncoding("UTF-8");
		return mv;
		
	}
	//录用客户面试
	public ModelAndView customerInterviewPage(HttpServletRequest request, HttpServletResponse response,ContractJobCvInterviewQuery contractJobCvInterviewQuery) throws IOException {
		OnlineManager onlineManager=super.getOnlineManager(request, response);
		if (onlineManager!=null){
			OnlineUser onlineUser=onlineManager.getOnlineUser();
			contractJobCvInterviewQuery.setOnlineUser(onlineUser);
		}
		Page page = contractJobCvInterviewService.findJobCvInterviewPage(contractJobCvInterviewQuery);
		//query.getPageSize(), query.getPageNumber()
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/mobile/job/customerInterviewPage");
		
		mv.addObject("pages", page);
		response.setCharacterEncoding("UTF-8");
		return mv;
		
	}
    public ModelAndView jobDetail(HttpServletRequest request, HttpServletResponse response ) throws IOException {
		
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/mobile/job/jobDetail");		
		mv.addObject("id", request.getParameter("id"));
		response.setCharacterEncoding("UTF-8");
		return mv;
		
	}

}
